
 capture cd "D:\Dropbox\book_welfare\replication"

*****************
* genre and author gender 
*****************
use "data\book_author_mapping.dta", clear
	 
	keep book_id_csv mshare genre1 
	rename book_id_csv book_id 
	
	gsort book_id -mshare +genre1
	gen keep = book_id>book_id[_n-1]
	keep if keep==1 
	drop keep 
	
	
	duplicates drop 
	tempfile bookgender 
	save `bookgender'
	
import delimited "data\goodreads_interactions.csv", clear 
	merge m:1 book_id using `bookgender'
	rename mshare authorgender 
	

	gen dromance = genre1=="romance"
	gen dchildren = genre1=="children"
	gen dcomics = genre1=="comics"
	gen dfantasy = genre1=="fantasy"
	gen dfiction = genre1=="fiction"
	gen dhistory = genre1=="history"
	gen dmystery = genre1=="mystery"
	gen dnonfiction = genre1=="non-fiction"
	gen dpoetry = genre1=="poetry"
	gen dyoungadult= genre1=="young-adult"

	

	
	collapse (mean) authorgender d*, by(user_id)
	
save "data\user_genre.dta", replace 
